package com.healthshare.parse.news;

import java.util.ArrayList;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import com.palmedia.framework.parse.BaseParse;




/**
 * @author xudeliang
 * 应用解析类
 */
public class AppListParse extends BaseParse
{

	
	public ArrayList<AppItem> appItems = new ArrayList<AppItem>();
	public AppListParse()
	{
		
	}
	
	
	@Override
	public boolean Parse(byte[]data)
	{
		boolean ret = super.Parse(data);
		if(!ret)
		{
			return false;
		}
		if(JSON==parseType)
		{
			try 
			{
				JSONArray ja = jsonObject.getJSONArray("applist");
				int len = ja.length();
				for(int i=0;i<len;i++)
				{
					JSONObject iobject =ja.getJSONObject(i);
					String appname = iobject.getString("appname");
					String appicon = iobject.getString("appicon");
					String appdes = iobject.getString("appdes");
					String apppath = iobject.getString("apppath");
					int shelves = iobject.getInt("shelves");
					
					AppItem kv = new AppItem();
					kv.appname = appname;
					kv.appicon = appicon;
					kv.appdes = appdes;
					kv.apppath = apppath;
					kv.shelves = shelves;
					kv.appsize= iobject.getInt("appsize");
					appItems.add(kv);
				}
				return true;
			} 
			catch (JSONException e) 
			{
				e.printStackTrace();
			}
		}
		return false;
	}
	
	public class AppItem
	{
		public String appname;
		public String appicon;
		public String appdes;
		public String apppath;
		public int shelves;
		public int appsize;
	}
	
}
